import 'package:base/main.dart';
import 'package:framework/core/base_logic.dart';
import 'package:framework/main.dart';
import 'package:module_home/pages/home/view_models/banner_vm.dart';
import 'package:module_home/pages/home/view_models/domain_vm.dart';
import 'package:module_home/pages/home/view_models/function_vm.dart';

class HomeLogic extends BaseLogic {
  /// VM
  late BannerVM bannerVM;
  late DomainVM domainVM;
  late FunctionVm functionVM;

  @override
  Future<void> ready() async {
    Log.d("HomeLogic 获取数据 开始");
    setLoading(true);
    _iniVM();
    await Future.wait([
      domainVM.init(),
      functionVM.init(),
      bannerVM.init(),
    ]);
    Log.d("HomeLogic 获取数据 结束");
    setLoading(false);
  }

  /// 初始化vm
  _iniVM() {
    register(BannerVM());
    register(DomainVM());
    register(FunctionVm(), force: true);

    bannerVM = Get.find<BannerVM>();
    domainVM = Get.find<DomainVM>();
    functionVM = Get.find<FunctionVm>();
  }
}
